package klk.shop.objects;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;


import klk.shop.utilities.KlkConnectionPooling;

public class Tag {
	private int id;
	private String name;

	public Tag() {
	}

	public void fromSql(int id) {
		String sql = "SELECT id, name FROM tags WHERE id=" + id;
		Connection conn = null;
		Statement stmt = null;
		ResultSet rs = null;
		try{
			conn = KlkConnectionPooling.getConnection();
			stmt = conn.createStatement();
			rs = stmt.executeQuery(sql);
			rs.next();
			name = rs.getString("name");
			this.id = id;
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		finally {
			if (rs != null)
				try {
					rs.close();
				} catch (Exception e) {
				}
			if (stmt != null)
				try {
					stmt.close();
				} catch (Exception e) {
				}
			if (conn != null)
				try {
					conn.close();
				} catch (Exception e) {
				}
		}
	}
	public String toHtml()
	{
		return "<br />"+name;
	}
}
